import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/:pathMatch(.*)*', // 匹配所有未定义的路由
      name: 'NotFound',
      component: () => import('@/views/404.vue'), // 404 页面组件
    },
    {
      path: '/gt/tj-:id/:type?/:type2?',
      name: 'tj_box',
      component: () => import('@/views/gt/tj.vue')
    },
    {
      path: '/gt/hm-:id/:type?/:type2?',
      name: 'home',
      component: () => import('@/views/gt/home.vue')
    },
    {
      path: '/gt/am-:id/:type?/:type2?',
      name: 'admin',
      component: () => import('@/views/gt/admin.vue')
    },
    {
      path: '/gt/gn-:id/:type?/:type2?',
      name: 'gbox',
      component: () => import('@/views/gt/gn.vue')
    },
    {
      path: '/gt/gh-:id-:guild_id?-:season?',
      name : 'guild',
      component: () => import('@/views/gt/gh.vue')
    },

    {
      path: '/rinbot/:id/:guild_id?/:season?',
      name : 'rinbot',
      component: () => import('@/views/rinbot/main.vue')
    },
    //默认页
    {
      path: '/',
      name : 'base',
      component: () => import('@/views/404.vue'), // 404 页面组件
    },
    
  ]
})

router.afterEach((to, from) => {
  window.scrollTo({
    top: 0,
    behavior: 'smooth', // 可选：平滑滚动
  });
});

export default router
